2#
# @lc app=leetcode.cn id=58 lang=python3
#
# [58] 最后一个单词的长度
#

# @lc code=start
class Solution:
    def lengthOfLastWord(self, s: str) -> int:
        returnNum = 0
        isStart = False
        for i in range(len(s)-1, -1 , -1):
            if s[i] == ' ' and (not isStart): continue
            if s[i] == ' ' and isStart: break
            if s[i] != ' ':
                returnNum += 1
                isStart = True
        return returnNum        
            
            
            
            
# @lc code=end

